﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using FrontRoomCheck.Model;
using FrontRoomCheck.Utiltiy;
using ModelCheckUtility.ControlLayer;
using ModelCheckUtility.ModelLayer;

namespace FrontRoomCheck.FindRoomMethod
{
	public static class FindFrontRoom_ElementMethod
	{
		public static List<FrontRoomPacker> FindAllRoomPackers(Document use_Document, List<Level> useLevels, List<Phase> usePhase, out List<FrontRoomPacker> allPackers)
		{
			List<FrontRoomPacker> list;
			FindFrontRoom_ElementMethod.FindStairRoom(use_Document, useLevels, usePhase, out allPackers, out list);
			List<FrontRoomPacker> list2 = new List<FrontRoomPacker>();
			List<int> list3 = new List<int>();
			foreach (FrontRoomPacker frontRoomPacker in list)
			{
				foreach (FrontRoomPacker frontRoomPacker2 in frontRoomPacker.NearFrontRooms)
				{
					if (frontRoomPacker2.LstHostElementPacker.Count == 0 && frontRoomPacker2.thisFrontRoomDoor.Count > 1 && !list3.Contains(frontRoomPacker2.ThisElementPackerId))
					{
						list2.Add(frontRoomPacker2);
						list3.Add(frontRoomPacker2.ThisElementPackerId);
					}
				}
			}
			return list2;
		}

		public static void FindStairRoom(Document use_Document, List<Level> useLevels, List<Phase> usePhase, out List<FrontRoomPacker> allPackers, out List<FrontRoomPacker> stairRoomValues)
		{
			stairRoomValues = new List<FrontRoomPacker>();
			List<FrontRoomPacker> list = new List<FrontRoomPacker>();
			list = BaseRoomFinder<FrontRoomPacker, FrontRoomDoorPacker, BaseBoundarySegmentPacker, BaseHostInRoomPacker>.GetRoomPacker(use_Document, useLevels, usePhase, new List<BuiltInCategory>
			{
				(BuiltInCategory)(-2000120)
			}, null, null, null, null);
			allPackers = list;
			foreach (FrontRoomPacker frontRoomPacker in list)
			{
				if (frontRoomPacker.LstHostElementPacker.Count > 0 && Utility.JudgeStairRoomByArea(use_Document, frontRoomPacker))
				{
					stairRoomValues.Add(frontRoomPacker);
				}
			}
		}
	}
}
